package com.frank.subject.domain.job;

import com.frank.subject.domain.service.SubjectLikedDomainService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.stereotype.Component;

/**
 * @author Frank Zou
 * @version v0.0.1
 * @date 2025/3/12
 * @description 同步点赞数据
 */
@Component
public class SyncSubjectLikedJob {

    private final SubjectLikedDomainService subjectLikedDomainService;

    public SyncSubjectLikedJob(SubjectLikedDomainService subjectLikedDomainService) {
        this.subjectLikedDomainService = subjectLikedDomainService;
    }

    @XxlJob("syncSubjectLikedJobHandler")
    public void syncSubjectLikedJobHandler() {
        XxlJobHelper.log("XXL Job, syncSubjectLikedJobHandler start.");
        try {
            subjectLikedDomainService.syncSubjectLiked();
        }catch (Exception e){
            XxlJobHelper.log("XXL Job, syncSubjectLikedJobHandler, error:" + e.getMessage(), e);
        }
    }
}
